import requests from './request'
import mockRequests from './mockrequests'

// 请求三级分类
export const requestCategoryList = () => {
  return requests({ url: '/product/getBaseCategoryList', method: 'get' })
}
// 请求mock模拟的banner数据
export const requestBannerList = () => {
  return mockRequests({ url: '/banner', method: 'get' })
}
// 请求mock模拟的floor数据
export const requestFloorList = () => {
  return mockRequests({ url: '/floor', method: 'get' })
}
// 请求搜索的数据 post 带参数(至少是空对象)
// 不传参数将会请求失败
export const requestList = (data) => {
  return requests({ url: '/list', method: 'post', data })
}
// 请求详情页的数据 get 带产品id参数
export const requestGoodinfo = (data) => {
  return requests({ url: `/item/${data}`, method: 'get' })
}
// 将购物车的数据传给服务器带 参数: 产品id 产品个数   post 
export const requestShopChart = (skuId, skuNum) => {
  return requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })
}
// 获取购物车数据
// /cart/cartList  get
export const requestShopChartInfo = () => {
  return requests({ url: `/cart/cartList`, method: 'get' })
}
// 删除购物车的某一个数据
// /cart/deleteCart/{skuId}
export const deleteShopCartById = (skuId) => {
  return requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })
}
// 改变选框状态发送请求
// /cart/checkCart/{skuID}/{isChecked}
export const updateShopCartStatusById = (skuId, isChecked) => {
  return requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })
}
// 获取验证码
// /user/passport/sendCode/{phone} get
export const getCode = (phone) => {
  return requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })
}
// 注册
// /user/passport/register
export const reqRegister = (data) => {
  return requests({ url: `/user/passport/register`, data, method: 'post' })
}
// 登录
// /user/passport/login
export const getLogin = (data) => {
  return requests({ url: `/user/passport/login`, data, method: 'post' })
}
// 获取登录后的用户信息
// /user/passport/auth/getUserInfo
export const getUserInfo = () => {
  return requests({ url: `/user/passport/auth/getUserInfo`, method: 'get' })
}
// 退出登录
// /user/passport/logout
export const loginOut = () => {
  return requests({ url: `/user/passport/logout`, method: 'get' })
}
// 获取用户地址信息
// /user/userAddress/auth/findUserAddressList
export const getAddress = () => {
  return requests({ url: `/user/userAddress/auth/findUserAddressList`, method: 'get' })
}
// 获取订单信息
// /order/auth/trade
export const getOrder = () => {
  return requests({ url: `/order/auth/trade`, method: 'get' })
}
// 提交订单
// /order/auth/submitOrder?tradeNo={tradeNo}
export const submitOrder = (tradeNo, data) => {
  return requests({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'post' })
}
// 获取订单信息
// /payment/weixin/createNative/{orderId}
export const getUserOrder = (orderId) => {
  return requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' })
}
// 订单是否支付成功
// /payment/weixin/queryPayStatus/{orderId}
export const getOrderSuccess = (orderId) => {
  return requests({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' })
}
//  获取个人中心订单列表
// /order/auth/{page}/{limit}
export const getOrderList = (page, limit) => {
  return requests({ url: `/order/auth/${page}/${limit}`, method: 'get' })
}